
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>sass和rem · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Landen">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-image-captions/image-captions.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="flex、media、栅格化.html" />
    
    
    <link rel="prev" href="变换、过渡、动画.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../01html/html简介.html">
            
                <a href="../01html/html简介.html">
            
                    
                    HTML
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../01html/01html.html">
            
                <a href="../01html/01html.html">
            
                    
                    a链接、图片
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../01html/02html.html">
            
                <a href="../01html/02html.html">
            
                    
                    列表、表格、表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../01html/h5新增.html">
            
                <a href="../01html/h5新增.html">
            
                    
                    h5新增
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="css简介.html">
            
                <a href="css简介.html">
            
                    
                    CSS
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="居中、省略、清浮.html">
            
                <a href="居中、省略、清浮.html">
            
                    
                    居中、省略、清浮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="浮动和定位.html">
            
                <a href="浮动和定位.html">
            
                    
                    浮动和定位
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="变换、过渡、动画.html">
            
                <a href="变换、过渡、动画.html">
            
                    
                    变换、过渡、动画
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.4" data-path="sass和rem.html">
            
                <a href="sass和rem.html">
            
                    
                    sass和rem
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="flex、media、栅格化.html">
            
                <a href="flex、media、栅格化.html">
            
                    
                    flex、media、栅格化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../03js/js简介.html">
            
                <a href="../03js/js简介.html">
            
                    
                    JavaScript
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../03js/数据类型.html">
            
                <a href="../03js/数据类型.html">
            
                    
                    数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../03js/字符串.html">
            
                <a href="../03js/字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../03js/数组.html">
            
                <a href="../03js/数组.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../03js/回流和重绘.html">
            
                <a href="../03js/回流和重绘.html">
            
                    
                    回流和重绘
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../03js/浏览器的渲染过程.html">
            
                <a href="../03js/浏览器的渲染过程.html">
            
                    
                    浏览器的渲染过程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../03js/十大排序算法.html">
            
                <a href="../03js/十大排序算法.html">
            
                    
                    十大排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../03js/对象的构建.html">
            
                <a href="../03js/对象的构建.html">
            
                    
                    对象的构建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../03js/this.html">
            
                <a href="../03js/this.html">
            
                    
                    this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../03js/bind&call&apply.html">
            
                <a href="../03js/bind&call&apply.html">
            
                    
                    bind&call&apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../03js/函数.html">
            
                <a href="../03js/函数.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="../03js/变量提升.html">
            
                <a href="../03js/变量提升.html">
            
                    
                    变量提升
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.12" data-path="../03js/作用域.html">
            
                <a href="../03js/作用域.html">
            
                    
                    作用域
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.13" data-path="../03js/对象.html">
            
                <a href="../03js/对象.html">
            
                    
                    对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.14" data-path="../03js/存储.html">
            
                <a href="../03js/存储.html">
            
                    
                    存储
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.15" data-path="../03js/事件.html">
            
                <a href="../03js/事件.html">
            
                    
                    事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.16" data-path="../03js/图片预览.html">
            
                <a href="../03js/图片预览.html">
            
                    
                    图片预览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.17" data-path="../03js/防抖节流.html">
            
                <a href="../03js/防抖节流.html">
            
                    
                    防抖节流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.18" data-path="../03js/同步异步.html">
            
                <a href="../03js/同步异步.html">
            
                    
                    同步异步
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.19" data-path="../03js/babel入门.html">
            
                <a href="../03js/babel入门.html">
            
                    
                    babel入门
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.20" data-path="../03js/nvm.html">
            
                <a href="../03js/nvm.html">
            
                    
                    nvm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.21" data-path="../03js/ES6.html">
            
                <a href="../03js/ES6.html">
            
                    
                    ES6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.22" data-path="../03js/ES6-ES11.html">
            
                <a href="../03js/ES6-ES11.html">
            
                    
                    ES6-ES11
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >sass和rem</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
                                <section class="normal markdown-section">
                                
                                <h2 id="sass&#x6700;&#x6210;&#x719F;-&#x6700;&#x5E73;&#x7A33;-&#x6700;&#x5F3A;&#x5927;-&#x6700;&#x4E13;&#x4E1A;&#x7684;css&#x7684;&#x6269;&#x5C55;&#x5DE5;&#x5177;">Sass&#x6700;&#x6210;&#x719F; &#x6700;&#x5E73;&#x7A33; &#x6700;&#x5F3A;&#x5927; &#x6700;&#x4E13;&#x4E1A;&#x7684;CSS&#x7684;&#x6269;&#x5C55;&#x5DE5;&#x5177;</h2>
<pre><code>    1.css&#x6269;&#x5C55;&#x5DE5;&#x5177;
    sass  less  stylus
    &#x5DE5;&#x5177;  &#x7F16;&#x8BD1;&#x73AF;&#x5883;  &#x8BED;&#x6CD5;

    2.sass&#x5DE5;&#x4F5C;&#x6D41;&#x7A0B;
    scss scss/index.scss css/index.css
    &#x8DEF;&#x5F84;&#x4E0D;&#x53EF;&#x4EE5;&#x6709;&#x4E2D;&#x6587;

    3.&#x70ED;&#x66F4;&#x65B0;
    scss --watch scss/index.scss:css/index.css
</code></pre><ul>
<li><p>scss</p>
<pre><code class="lang-scss">  @<span class="hljs-keyword">charset</span> <span class="hljs-string">&quot;UTF-8&quot;</span>;

  <span class="hljs-variable">$baseFontSize</span>: <span class="hljs-number">25</span>;
  @function r(<span class="hljs-variable">$px</span>) {
      @return <span class="hljs-variable">$px</span> / <span class="hljs-variable">$baseFontSize</span> * 1rem;
  }
</code></pre>
</li>
<li><p>js </p>
<pre><code class="lang-js">  <span class="hljs-comment">/*&#x52A8;&#x6001;&#x6539;&#x53D8;&#x6839;&#x5143;&#x7D20;&#x5B57;&#x4F53;&#x5927;&#x5C0F;*/</span>
  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">recalc</span>(<span class="hljs-params"></span>) </span>{
      <span class="hljs-keyword">var</span> clientWidth = <span class="hljs-built_in">document</span>.documentElement.clientWidth;
      <span class="hljs-keyword">if</span>(!clientWidth) <span class="hljs-keyword">return</span>;
      <span class="hljs-built_in">document</span>.documentElement.style.fontSize = <span class="hljs-number">50</span> * (clientWidth / <span class="hljs-number">750</span>) + <span class="hljs-string">&apos;px&apos;</span>;
  }

  <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">initRecalc</span>(<span class="hljs-params"></span>) </span>{
      recalc();
      <span class="hljs-keyword">var</span> resizeEvt = <span class="hljs-string">&apos;osrientationchange&apos;</span> <span class="hljs-keyword">in</span> <span class="hljs-built_in">window</span> ? <span class="hljs-string">&apos;orientationchange&apos;</span> : <span class="hljs-string">&apos;resize&apos;</span>;
      <span class="hljs-keyword">if</span>(!<span class="hljs-built_in">document</span>.addEventListener) <span class="hljs-keyword">return</span>;
      <span class="hljs-built_in">window</span>.addEventListener(resizeEvt, recalc, <span class="hljs-literal">false</span>);
      <span class="hljs-built_in">document</span>.addEventListener(<span class="hljs-string">&apos;DOMContentLoaded&apos;</span>, recalc, <span class="hljs-literal">false</span>);
  }
  initRecalc();
</code></pre>
</li>
</ul>

                                
                                </section>
                            
                        </div>
                    </div>
                
            </div>

            
                
                <a href="变换、过渡、动画.html" class="navigation navigation-prev " aria-label="Previous page: 变换、过渡、动画">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="flex、media、栅格化.html" class="navigation navigation-next " aria-label="Next page: flex、media、栅格化">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"sass和rem","level":"1.3.4","depth":2,"next":{"title":"flex、media、栅格化","level":"1.3.5","depth":2,"path":"md/02css/flex、media、栅格化.md","ref":"./md/02css/flex、media、栅格化.md","articles":[]},"previous":{"title":"变换、过渡、动画","level":"1.3.3","depth":2,"path":"md/02css/变换、过渡、动画.md","ref":"./md/02css/变换、过渡、动画.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","-sharing","toggle-chapters","image-captions","-anchor-navigation","-anchor-navigation-ex"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"image-captions":{"attributes":{"style":"left: 50%;position: relative;transform: translateX(-50%);"},"caption":"图 _PAGE_LEVEL_._PAGE_IMAGE_NUMBER_ - _CAPTION_","align":"center","variable_name":"_pictures"},"fontsettings":{"theme":"night","family":"sans","size":2},"toggle-chapters":{},"highlight":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Landen","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{"_pictures":[]},"gitbook":"3.x.x"},"file":{"path":"md/02css/sass和rem.md","mtime":"2020-06-08T11:52:28.122Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-08-17T10:41:18.504Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

